package com.orange.modules.dao;

import java.sql.SQLException;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.orange.dbhelp.DbHelper;
import com.orange.modules.entity.school_data.AuthTeachResource;

@Repository
public class AuthTeachResourceDataRepository {

	@Resource(name = "dbHelper")
	private DbHelper dbHelper;
	
	@Autowired
	private AuthTeachResourceDataDao authTeachResourceDataDao;
	
	
	public void insertTeachResource(AuthTeachResource atr) throws SQLException{
		authTeachResourceDataDao.save(atr);
	}
	
	
	public AuthTeachResource queryAuthTeachResourceDataBySchoolId(String schoolId,String loginType) throws SQLException{
		String sql = "SELECT t.p_id as pid,t.s_latest_professional_construction_time as latestProfessionalConstructionTime,"
				+ "t.s_professional_training_program as professionalTrainingProgram,t.s_required_courses_num as requiredCoursesNum,"
				+ "t.s_elective_courses_num as electiveCoursesNum,t.s_online_course_time as onlineCourseTime,"
				+ "t.s_online_assessment_time as onlineAssessmentTime,t.s_teaching_cycle as teachingCycle,"
				+ "t.s_teaching_satisfaction as teachingSatisfaction,t.s_credit_system_time as creditSystemTime,"
				+ "t.s_basic_course_credit as basicCourseCredit,t.s_professional_course_credits as professionalCourseCredits,"
				+ "t.s_curriculum_credits as curriculumCredits,t.s_county_num as countyNum,t.s_practice_base as practiceBase,"
				+ "t.s_education_practice_base as educationPracticeBase,t.s_teaching_practice_time as teachingPracticeTime,"
				+ "t.s_educational_probation as educationalProbation,t.s_educational_practice as educationalPractice,"
				+ "t.s_educational_practice_time as educationalPracticeTime,t.s_base_instructor as baseInstructor,"
				+ "t.s_ratio_teacher_student as ratioTeacherStudent,t.s_fulltime_teachers_latest as fulltimeTeachersLatest,"
				+ "t.s_parttime_teachers_latest as parttimeTeachersLatest,t.s_createtime as createtime,"
				+ "t.s_id as sid,t.login_type as loginType,t.s_status as status,t.s_remark as remark FROM t_auth_teach_resource t WHERE t.s_id =?";
		if(StringUtils.isNotBlank(loginType)){
			sql+="AND  t.login_type ='"+loginType+"'";
		}
		AuthTeachResource atr = dbHelper.getBean(sql, AuthTeachResource.class,schoolId);
		return atr;
	}
 	
}
